package com.hhf.feiojcommonservice.model.enums;

import org.apache.commons.lang3.ObjectUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author hhf
 * @Date 2024/10/25
 * @Description
 */
public enum QuestionSubmitLanguageEnum {

    /**
     * java
     */
    JAVA("java"),
    /**
     * c
     */
    C("c"),
    /**
     * cpp
     */
    CPP("cpp"),
    /**
     * python
     */
    PYTHON("python"),
    /**
     * golang
     */
    GOLANG("golang");

    private final String value;

    QuestionSubmitLanguageEnum(String value) {
        this.value = value;
    }

    /**
     * 获取值列表
     *
     * @return
     */
    public static List<String> getValues() {
        return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
    }

    /**
     * 根据 value 获取枚举
     *
     * @param value
     * @return
     */
    public static QuestionSubmitLanguageEnum getEnumByValue(String value) {
        if (ObjectUtils.isEmpty(value)) {
            return null;
        }
        for (QuestionSubmitLanguageEnum questionSubmitLanguageEnum : QuestionSubmitLanguageEnum.values()) {
            if (questionSubmitLanguageEnum.value.equals(value)) {
                return questionSubmitLanguageEnum;
            }
        }
        return null;
    }

    public String getValue() {
        return value;
    }

}
